#/bin/bash
url="http://47.96.191.61:9000/#!/1/docker/stacks/xdweb?id=32&type=2&external=false"
npm i && npm run build:prod
if [ -d "./docker/dist/" ]; then
    rm -rf ./docker/dist
fi
cp -r ./dist ./docker/

str=$(cat ./docker/docker.sh | tail -n 1)
str=${str#*:} # 取”:“后的内容
array=(${str//./ }) # 以“.”分割
# v1.v2.v3
declare -i v1=${array[0]}
declare -i v2=${array[1]}
declare -i v3=${array[2]}

echo "#/bin/bash
docker build -t registry.cn-hangzhou.aliyuncs.com/inpm/xd_work_web:$v1.$v2.$[v3+1] ./
docker push registry.cn-hangzhou.aliyuncs.com/inpm/xd_work_web:$v1.$v2.$[v3+1]" > ./docker/docker.sh

echo "version: '2'

services:
  nginx:
    image: registry.cn-hangzhou.aliyuncs.com/inpm/xd_work_web:$v1.$v2.$[v3+1]
    container_name: xd_work_web
    restart: always
    ports:
      - 9527:80" > ./docker/docker-compose.yml

cd docker && sh docker.sh

echo "请到这里修改版本号：$url"
echo "web当前版本号是：$v1.$v2.$[v3+1]"